package com.example.Annocation.compentScann;

import org.springframework.core.io.Resource;
import org.springframework.core.type.AnnotationMetadata;
import org.springframework.core.type.ClassMetadata;
import org.springframework.core.type.classreading.MetadataReader;
import org.springframework.core.type.classreading.MetadataReaderFactory;
import org.springframework.core.type.filter.TypeFilter;

import java.io.IOException;

/**
 * @Description TODO
 * @Date 2024/5/14 19:14
 * @Created by houjunfeng
 */
public class




MyTypeFilter implements TypeFilter {
    @Override
    //MetadataReader 获取正在扫描类的信息
    //MetadataReaderFactory 获取其他任何类的信息
    public boolean match(MetadataReader var1, MetadataReaderFactory var2)throws IOException {
        //获取当前类注解信息
        AnnotationMetadata annotationMetadata = var1.getAnnotationMetadata();
        //获取当前正在扫描类的信息
        ClassMetadata classMetadata = var1.getClassMetadata();
        //获取当前类的路径
        Resource resource = var1.getResource();
        //获取当前类的类名
        String classname = classMetadata.getClassName();
        System.out.println("------>"+annotationMetadata);
        System.out.println("------>"+classMetadata);
        System.out.println("------>"+resource);
        System.out.println("------>"+classname);
        if(classname.contains("er")){
            return true;
        }
        return  false;
    }

}
